package ru.ifmo.rybakov.muclumon;

import org.joda.time.DateTime;


public class PropertyValueFactory {

	/**
	 * This method tries to guess the type of property value and returns
	 * appropriate property value entity.
	 * 
	 * @param name
	 * @param value
	 */
	public static final PropertyValue create(String name, String value) {
		try {
			Double d = Double.valueOf(value);
			return new NumericValue(PropertyManager.get(name), d);
		} catch (NumberFormatException e) {} // ok, not a number
		
		return new StringValue(PropertyManager.get(name), value);
	}

	public static final NumericValue createNumericValue(String name, Double value) {
		return new NumericValue(PropertyManager.get(name), value);
	}
	
	public static final StringValue createStringValue(String name, String value) {
		return new StringValue(PropertyManager.get(name), value);
	}
	
	public static final DateTimeValue createDateTimeValue(String name, DateTime value) {
		return new DateTimeValue(PropertyManager.get(name), value);
	}
}
